import random
import numpy as np


class FPGASimulator:
    def __init__(self,pltfpga):
        self.plt_fpga = pltfpga
        #self.times=1#生成频率

    # 模拟生成 FPGA 数据
    def generate_data(self):
        data = [random.randint(0, 30) for _ in range(180)]  # 生成前180个0-30的随机数
        # 在第180个位置插入一个大值（如41000），然后锯齿状迅速回落
        data.append(1000);data.append(1000);data.append(1000);data.append(1000)
        data.append(3000);data.append(3000);data.append(3000);data.append(3000)
        data.append(5000);data.append(5000);data.append(5000);data.append(5000)
        data.append(41000);data.append(41000);data.append(41000);data.append(41000)
        data.append(45000);data.append(45000);data.append(45000);data.append(45000)
        data.append(8000);data.append(8000);data.append(8000);data.append(8000)
        data.append(1000);data.append(1000);data.append(1000);data.append(1000)
        data.append(500);data.append(500);data.append(500);data.append(500)
        data.append(200);data.append(200);data.append(200);data.append(200)
        for i in range(350-len(data)):
            data.append(random.randint(0, 30))
        data.append(1000/10)
        data.append(3000/10)
        data.append(5000/10)
        data.append(41000/10)
        data.append(45000/10)
        data.append(8000/10)
        data.append(1000/10)
        data.append(500/10)
        data.append(200/10)
        for i in range(500-len(data)):
            data.append(random.randint(0, 30))



        #data = [sum(data[:i + 1]) for i in range(len(data))]  # 每个元素是前面所有元素的和
        # for i in range(500):
        #     self.plt_fpga.add_data(data[i])


